<?php
/**
 * Created by PhpStorm.
 * User: Dave
 * Date: 2018/4/23
 * Time: 11:10
 */

ini_set('display_errors', 1);
error_reporting(-1);
require_once '/data/wwwroot/g_vendor/autoload.php';

use Biz\model\trade\ShopCourier as mShopCourier;
use Biz\cache\IniCourier as cIniCourier;

$file_path = "/home/adm_rsync_dir/courier.json";


try{

    $field = ['courier_id', 'courier_name','courier_code','courierbird_code','trackingmore_code','courier_website', 'courier_telephone'];
    $result = [];

    $courierList = mShopCourier::getCourierList($field);
    if (!empty($courierList)){

        $reflect = new ReflectionClass('\Biz\model\ShopBasicInfo');

        $selfOperatedOnline = $reflect->hasMethod('checkIsSelfOperated');

        if(!$selfOperatedOnline){
            $courierList = array_filter($courierList,function($v){
                if($v['courier_id'] != 150){
                    return true;
                }
                return false;
            });
        }




        $result['courier'] = array_values($courierList);

        $reg = cIniCourier::setCourier($result);

        echo printf("%s,%s",date('Y-m-d H:i:s'),'同步成功');
    } else{
        echo printf("%s,%s",date('Y-m-d H:i:s'),'当前没有需要同步的数据');
    }

} catch (\Exception $e){

    echo printf("出错,%s",$e->getMessage());
}








